package main

import (
	"errors"
	"gitee.com/dennis-mxx/gcode-common/mcontext"
	"gitee.com/dennis-mxx/gcode-common/menv"
	"gitee.com/dennis-mxx/gcode-common/mlogger"
	"gitee.com/dennis-mxx/gcode-data/mdata"
)

func main() {
	mlogger.InitZap("test", &menv.Logger{Level: "info"})
	mtx := mcontext.WithLogger(mlogger.DefaultTraceLogger())
	mtx.SetTraceId("main")
	fileRender := menv.FileRender{Env: "dev"}
	fileRender.Render()
	if err := menv.Unmarshal(menv.Environment); err != nil {
		panic(errors.Join(err, errors.New("load config exception")))
	}

	mdata.InitMysql(mtx.Logger(), menv.Environment.Mysql)

	appFunc := NewAppFunc(mtx)

	page := appFunc.SelectPage()
	println(page)
	list := appFunc.SelectActiveApp()
	println(list)
	cs := appFunc.SelectByAppId("iretail")

	println(cs)
	mtx.Close(true)
	cs = appFunc.SelectByAppId("iretail")
	println(cs)
	println(list)

}
